package com.example.usermanager.tools;

import com.example.usermanager.model.UserInfo;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

public class SessionUtil {

    /**
     *
     * @param request
     * @return
     */
    public static UserInfo getUserBySession(HttpServletRequest request){
        HttpSession session = request.getSession(false);
        if(session != null){
            return (UserInfo) session.getAttribute(AppConfig.USERINFO_SESSION_KEY);
        }
        return null;
    }
}
